package top.mcwebsite.playandroid.common.network.model

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient

@Serializable
data class RespModel<T>(
    @SerialName("errorCode")
    val errorCode: Int,
    @SerialName("errorMsg")
    val errorMsg: String,
    @SerialName("data")
    val data: T? = null,
) {
    @Transient
    val error: Throwable? = null
}

fun <T> RespModel<T>.error(
    errorCode: Int,
    errorMsg: String,
    error: Throwable,
): RespModel<T> = RespModel<T>(
    errorCode = errorCode,
    errorMsg = errorMsg,
)